package com.tutu.controller.api;

import com.tutu.core.api.WechatApiUrls;
import com.tutu.core.bean.Result;
import com.tutu.utils.JsonUtil;
import com.tutu.utils.WxMsgPushUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping(value = "/weChat")
public class WeChatApi {

    @RequestMapping(WechatApiUrls.getToken)
    public String getToken() {
        Map<String, Object> tokenMap = new HashMap<>();

        tokenMap.put("accessToken", WxMsgPushUtil.getToken());
        tokenMap.put("expireTime", WxMsgPushUtil.tokenExpireTime);

        return JsonUtil.obj2ApiJson(Result.successApi(tokenMap));
    }
}
